package cc.vv.btpartyjob.homepage.delegate

import android.widget.TextView
import cc.vv.baselibrary.view.BaseTopBarView
import cc.vv.baselibrary.view.LKAvatarView
import cc.vv.baselibrary.view.LKCircleImageView
import cc.vv.btpartyjob.homepage.R
import cc.vv.lkimagecomponent2.LKImage
import cc.vv.lkimagecomponent2.lib.mode.ScaleMode
import cc.vv.mvp.delegate.BaseAppDelegate

/**
 * 我的个人信息托管类
 * Created by Chen.qi on 2018/10/24.
 */
class MyInfoActivityDelegate : BaseAppDelegate() {

    override fun initWidget() {
    }

    override fun initLayoutRes(): Int {
        return R.layout.activity_my_info
    }


    /**设置标题右边按钮点击事件*/
    fun setTitleBackBtnOnClick(event: BaseTopBarView.EventInterface) {
        val titleBar = getView<BaseTopBarView>(R.id.btv_ami_top_bar)
        titleBar?.setEventInterface(event)
    }

    /**
     * 设置头像
     */
    fun setHeadImg(avatar: String?) {
        val headView = getView<LKCircleImageView>(R.id.liv_ami_userAvatar)
        LKImage.load().scale(ScaleMode.CENTER_CROP)
                .placeHolder(R.mipmap.icon_party_head_def)
                .error(R.mipmap.icon_party_head_def).load(avatar).into(headView)
    }

    /**
     * 设置姓名
     */
    fun setUnsrName(name: String?) {
        val viewInfo = getView<TextView>(R.id.tv_ami_name)
        viewInfo?.text = name
    }

    /**
     * 设置性别
     */
    fun setSex(sex: String?) {
        val viewInfo = getView<TextView>(R.id.tv_ami_gender)
        if ("m" == sex) {
            viewInfo?.text = "男"
        } else {
            viewInfo?.text = "女"
        }
    }


    /**
     * 设置电话
     */
    fun setUnsrPhone(phone: String?) {
        val viewInfo = getView<TextView>(R.id.tv_ami_phone)
        viewInfo?.text = phone
    }

    /**
     * 设置姓名
     */
    fun setChengNuo(chengNuo: String?) {
        val viewInfo = getView<TextView>(R.id.tv_ami_promise)
        viewInfo?.text = chengNuo
    }


}